<template>
<div>
    <el-aside class="myaside" width="200px">
        <el-menu :default-openeds="['1','2']" :default-active="this.activeName2">
            <el-submenu index="1">
                <template slot="title"><i class="el-icon-user"></i>个人信息</template>
                <el-menu-item-group>
                    <el-menu-item index="1-1" @click="menuitem1">修改密码</el-menu-item>
                    <el-menu-item index="1-2" @click="menuitem2">个人资料</el-menu-item>
                    <el-menu-item index="1-3" @click="menuitem3">上传头像</el-menu-item>
                    <el-menu-item index="1-4" @click="menuitem4">收货管理</el-menu-item>
                </el-menu-item-group>
            </el-submenu>
            <el-submenu index="4">
                <template slot="title"><i class="el-icon-message"></i>选项二</template>
                <el-menu-item-group>
                    <el-menu-item index="4-1">选项1</el-menu-item>
                    <el-menu-item index="4-2">选项2</el-menu-item>
                    <el-menu-item index="4-3">选项3</el-menu-item>
                    <el-menu-item index="4-4">选项4</el-menu-item>
                </el-menu-item-group>
            </el-submenu>
            <el-submenu index="3">
                <template slot="title"><i class="el-icon-setting"></i>设置</template>
                <el-menu-item-group>
                    <el-menu-item index="3-1">选项1</el-menu-item>
                    <el-menu-item index="3-2">选项2</el-menu-item>
                </el-menu-item-group>
            </el-submenu>
        </el-menu>
    </el-aside>
</div>
</template>

<script>
    export default {
        name:'XiaoLeftAside',
        data(){
            return{
                // activeName2:'1-2',
                activeName2:'',
                activeName:'',
                // activeName: 'second',   //默认打开el-tabs的第几个
            }
        },
        methods:{
            menuitem1(){
                console.log(this);
                this.$router.push({name:'xchangepsw'})
                this.activeName='first';
            },
            menuitem2(){
                this.$router.push({name:'xperdata'})
                this.activeName='second';
            },
            menuitem3(){
                this.$router.push({name:'xuploadavatar'})
                this.activeName='third';
            },
            menuitem4(){
                this.$router.push({name:'xrecmanage'})
                this.activeName='fourth';
            },
        },
        watch:{
            activeName(val){
                this.$bus.$emit('LeftAsidetoELMainTabs',val)
            }
        },
        mounted(){
            this.$bus.$on('ELMainTabstoLeftAside',(val)=>{
                this.activeName2=val
            })
        },
        beforeDestroy(){
            this.$bus.$off('ELMainTabstoLeftAside')
        },
    }
</script>

<style>

</style>